//
//  SearchOtherTableViewCell.m
//  miaopai
//
//  Created by duyifang on 15/11/19.
//  Copyright © 2015年 Crow Zhang. All rights reserved.
//

#import "SearchOtherTableViewCell.h"
#import <SDWebImageManager.h>
#import <UIImageView+WebCache.h>
@interface SearchOtherTableViewCell ()

@property(nonatomic, retain) UIImageView *posterImageView;

@property(nonatomic, retain) UILabel *titleLabel;

@end

@implementation SearchOtherTableViewCell

- (void)dealloc
{
    [_posterImageView release];
    [_titleLabel release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.posterImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_posterImageView];
        [_posterImageView release];
        self.titleLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_titleLabel];
        [_titleLabel release];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat posterWidth = self.frame.size.height - 10;
    _posterImageView.frame = CGRectMake(20, 5, posterWidth, posterWidth);
    _posterImageView.backgroundColor = [UIColor yellowColor];
    
    _titleLabel.frame = CGRectMake(_posterImageView.frame.origin.x + _posterImageView.frame.size.width + 10, (self.frame.size.height - 30) / 2, self.frame.size.width - 40 - posterWidth - 10, 30);
}

- (void)setHotModel:(NewsTopicModel *)hotModel
{
    if (_hotModel != hotModel) {
        [_hotModel release];
        _hotModel = [hotModel retain];
    }
    [_posterImageView sd_setImageWithURL:[NSURL URLWithString:hotModel.topic.img] placeholderImage:[UIImage imageNamed:@"zhanweitu"]];
     
    
    _titleLabel.text = hotModel.topic.name;
    _titleLabel.font = [UIFont systemFontOfSize:16];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
